home *** CD-ROM | disk | FTP | other *** search
- Subject: v16i033: Less, a pager that's more than more, Part04/04
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: ctnews!UNIX386!mark
- Posting-number: Volume 16, Issue 33
- Archive-name: less5/part04
-
- #! /bin/sh
- # This is a shell archive.
- # Remove anything before this line, then unpack it
- # by saving it into a file and typing "sh file".
-
- echo shar: Extracting \"linstall\"
- sed "s/^X//" >'linstall' <<'END_OF_FILE'
- X#! /bin/sh
- X# Installation script for less.
- X# This script prompts the operator for various information
- X# and constructs a makefile.
- X
- Xecho "This script will build a makefile for less."
- Xecho "If you already have a file called \"makefile\" it will be overwritten."
- Xecho "Press RETURN to continue."
- Xread ans
- X
- Xecho "I will ask you some questions about your system."
- Xecho "If you do not know the answer to any question,"
- Xecho "just press RETURN and I will choose a default for you."
- Xecho "Press RETURN now."
- Xread ans
- X
- XECHO=./vecho
- Xif [ ! -x $ECHO ]
- Xthen
- X echo "One moment..."
- X cc -o $ECHO vecho.c
- X echo ""
- Xfi
- X
- X$ECHO "Most Unix systems are derived from either System V"
- X$ECHO "or Berkeley BSD 4.1, 4.2, 4.3, etc."
- X$ECHO ""
- X$ECHO "Is your system closest to:"
- X$ECHO " 1. System V"
- X$ECHO " 2. BSD 4.1"
- X$ECHO " 3. BSD 4.2 or later"
- X$ECHO " 4. Xenix"
- X$ECHO "Enter a number, or just RETURN if you don't know: \c"
- Xread ans
- Xxenix=0
- Xcase "X$ans" in
- XX1) sys=sys5; sysname="System V" ;;
- XX2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
- XX3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
- XX4) sys=sys5; xenix=1; sysname="Xenix" ;;
- X*) sys=unknown ;;
- Xesac
- X$ECHO ""
- X
- XDATE=`date`
- Xcat >makefile <<EOF
- X# Makefile for "less"
- X# Generated $DATE by $0.
- XEOF
- X
- Xcat >>makefile <<"EOF"
- X#
- X# Invoked as:
- X# make all
- X# or make install
- X# Plain "make" is equivalent to "make all".
- X#
- X# If you add or delete functions, remake funcs.h by doing:
- X# make newfuncs
- X# This depends on the coding convention of function headers looking like:
- X# " \t public <function-type> \n <function-name> ( ... ) "
- X#
- X# Also provided:
- X# make lint # Runs "lint" on all the sources.
- X# make clean # Removes "less" and the .o files.
- X# make clobber # Pretty much the same as make "clean".
- X
- XSHELL = /bin/sh
- X
- XEOF
- X
- Xcat >defines.h <<EOF
- X/* Definition file for less */
- X/* Generated $DATE by $0. */
- X
- XEOF
- X
- Xcat >>defines.h <<EOF
- X/*
- X * Define XENIX if running under XENIX 3.0.
- X */
- X#define XENIX $xenix
- X
- XEOF
- X$ECHO ""
- X
- X
- X
- Xif [ "X$sys" = "Xunknown" ]
- Xthen
- X alldefault=0
- Xelse
- X def=yes
- X alldefault=1
- X $ECHO "Do you want to use ALL the defaults for $sysname?"
- X $ECHO " Enter \"yes\" if you have a STANDARD $sysname."
- X $ECHO " Enter \"no\" if you want to change any of the defaults. [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) alldefault=1 ;;
- X X[nN]*) alldefault=0 ;;
- X esac
- X $ECHO ""
- Xfi
- X
- Xif [ $alldefault = 0 ]
- Xthen
- X alloptional=0
- Xelse
- X def=yes
- X alloptional=1
- X $ECHO "Do you want to use all the optional features of less?"
- X $ECHO " Less has several features which you may or may not"
- X $ECHO " wish to include, such as shell escapes."
- X $ECHO " Enter \"yes\" if you want to include ALL the optional features."
- X $ECHO " Enter \"no\" if you want to select individual features. [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) alloptional=1 ;;
- X X[nN]*) alloptional=0 ;;
- X esac
- X $ECHO ""
- Xfi
- X
- X
- X
- Xdef=yes
- Xx=1
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Does your C compiler support the \"void\" type? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * VOID is 1 if your C compiler supports the "void" type,
- X * 0 if it does not.
- X */
- X#define VOID $x
- X
- XEOF
- X
- X
- X
- Xdef=long
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "What type is the \"offset\" argument to lseek? [$def] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X def=$ans
- X fi
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * offset_t is the type which lseek() returns.
- X * It is also the type of lseek()'s second argument.
- X */
- X#define offset_t $def
- X
- XEOF
- X
- X
- X
- X
- Xdef=yes; x=1
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Most Unix systems provide the stat() function."
- X $ECHO "Does your system have stat()? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * STAT is 1 if your system has the stat() call.
- X */
- X#define STAT $x
- X
- XEOF
- X
- X
- X
- X
- Xdef=yes; x=1
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Most Unix systems provide the perror() function."
- X $ECHO "Does your system have perror()? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * PERROR is 1 if your system has the perror() call.
- X * (Actually, if it has sys_errlist, sys_nerr and errno.)
- X */
- X#define PERROR $x
- X
- XEOF
- X
- X
- X
- X
- Xdef=yes; x=1
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Most Unix systems provide the time() function."
- X $ECHO "Does your system have time()? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * GET_TIME is 1 if your system has the time() call.
- X */
- X#define GET_TIME $x
- X
- XEOF
- X
- Xif [ $x = 0 ]
- Xthen
- X $ECHO "What is the APPROXIMATE performance of your"
- X $ECHO "machine, as a percentage of a Vax 11/750?"
- X $ECHO "(Enter 100 if your machine is as fast as a Vax,"
- X $ECHO " 50 if it is half as fast, 200 if it is twice as fast, etc.)"
- X $ECHO "The accuracy of this information is not critical."
- X while :
- X do
- X $ECHO "Percent of Vax 11/750 [100]: \c"
- X read ans
- X if [ "X$ans" = "X" ]
- X then
- X ans=100
- X fi
- X longloop=`expr "$ans" "*" 3`
- X if [ $? = 0 ]
- X then
- X break
- X fi
- X $ECHO "Enter a number please!"
- X done
- X $ECHO ""
- X
- X cat >>defines.h <<EOF
- X/*
- X * LONGLOOP is the number of lines we should process in the line number
- X * scan before displaying a warning that it will take a while.
- X */
- X#define LONGLOOP ($longloop)
- XEOF
- Xfi
- X
- X
- X
- X
- Xif [ "$sys" = "bsd" ]
- Xthen
- X def=no; x=0
- Xelse
- X def=yes; x=1
- Xfi
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Most System V systems have termio.h, while most"
- X $ECHO "Berkeley-derived systems have sgtty.h."
- X $ECHO "Does your system have termio.h? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * TERMIO is 1 if your system has /usr/include/termio.h.
- X * This is normally the case for System 5.
- X * If TERMIO is 0 your system must have /usr/include/sgtty.h.
- X * This is normally the case for BSD.
- X */
- X#define TERMIO $x
- X
- XEOF
- X
- X
- X
- X
- Xif [ "$sys" = "bsd" -a "$bsd41" = "0" ]
- Xthen
- X def=yes; x=1
- Xelse
- X def=no; x=0
- Xfi
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
- X $ECHO "Most System V and BSD 4.1 systems do not."
- X $ECHO "Does your system have sigsetmask()? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * SIGSETMASK is 1 if your system has the sigsetmask() call.
- X * This is normally the case only for BSD 4.2,
- X * not for BSD 4.1 or System 5.
- X */
- X#define SIGSETMASK $x
- X
- XEOF
- X
- X
- X
- Xif [ "$sys" = "bsd" ]
- Xthen
- X def=2; REGCMP=0;RECOMP=1
- Xelse
- X def=1; REGCMP=1;RECOMP=0
- Xfi
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "Most System V systems have the regcmp() function."
- X $ECHO "Most Berkeley-derived systems have the re_comp() function."
- X $ECHO "Does your system have:"
- X $ECHO " 1. regcmp"
- X $ECHO " 2. re_comp"
- X $ECHO " 3. neither [$def] \c"
- X read ans
- X case "X$ans" in
- X X1) REGCMP=1;RECOMP=0 ;;
- X X2) REGCMP=0;RECOMP=1 ;;
- X X3) REGCMP=0;RECOMP=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * REGCMP is 1 if your system has the regcmp() function.
- X * This is normally the case for System 5.
- X * RECOMP is 1 if your system has the re_comp() function.
- X * This is normally the case for BSD.
- X * If neither is 1, pattern matching is supported, but without metacharacters.
- X */
- X#define REGCMP $REGCMP
- X#define RECOMP $RECOMP
- X
- XEOF
- X
- X
- X
- X
- Xdef=yes
- Xx=1
- Xif [ $alloptional = 0 ]
- Xthen
- X $ECHO "Do you wish to allow shell escapes? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
- X * (This is possible only if your system supplies the system() function.)
- X */
- X#define SHELL_ESCAPE $x
- X
- XEOF
- X
- X
- X
- Xdef=yes
- Xx=1
- Xedname="vi"
- Xif [ $alloptional = 0 ]
- Xthen
- X $ECHO "Do you wish to allow editor escapes? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[nN]*) x=0; edname="" ;;
- X X[yY]*) x=1
- X $ECHO "What is the pathname of the default editor? [$edname] \c"
- X read ans
- X if [ "x$ans" != "x" ]
- X then
- X edname=$ans
- X fi
- X ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
- X * (This is possible only if your system supplies the system() function.)
- X * EDIT_PGM is the name of the (default) editor to be invoked.
- X */
- X#define EDITOR $x
- X#define EDIT_PGM "$edname"
- X
- XEOF
- X
- X
- X
- X
- Xdef=yes
- Xx=1
- Xif [ $alloptional = 0 ]
- Xthen
- X $ECHO "Do you wish to support \"tag\" files? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * TAGS is 1 if you wish to support tag files.
- X */
- X#define TAGS $x
- X
- XEOF
- X
- X
- X
- Xdef=yes
- Xx=1
- Xif [ $alloptional = 0 ]
- Xthen
- X $ECHO "Do you wish to allow user-defined key definitions? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- XUSERFILE=$x
- Xcat >>defines.h <<EOF
- X/*
- X * USERFILE is 1 if you wish to allow a .less file to specify
- X * user-defined key bindings.
- X */
- X#define USERFILE $x
- X
- XEOF
- X
- X
- X
- Xdef=yes
- Xx=1
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "If your system provides the popen() function and"
- X $ECHO "the \"$ECHO\" shell command, you may allow shell metacharacters"
- X $ECHO "to be expanded in filenames."
- X $ECHO "Do you wish to allow shell metacharacters in filenames? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
- X * This will generally work if your system provides the "popen" function
- X * and the "$ECHO" shell command.
- X */
- X#define GLOB $x
- X
- XEOF
- X
- X
- X
- Xdef=yes
- Xx=1
- Xif [ $alloptional = 0 ]
- Xthen
- X $ECHO "Do you wish to allow log files (-l option)? [$def] \c"
- X read ans
- X case "X$ans" in
- X X[yY]*) x=1 ;;
- X X[nN]*) x=0 ;;
- X esac
- X $ECHO ""
- Xfi
- Xcat >>defines.h <<EOF
- X/*
- X * LOGFILE is 1 if you wish to allow the -l option (to create log files).
- X */
- X#define LOGFILE $x
- X
- XEOF
- X
- Xcat >>defines.h <<EOF
- X/*
- X * ONLY_RETURN is 1 if you want RETURN to be the only input which
- X * will continue past an error message.
- X * Otherwise, any key will continue past an error message.
- X */
- X#define ONLY_RETURN 0
- X
- XEOF
- X
- Xcat >>makefile <<EOF
- X
- X##########################################################################
- X# Compilation environment.
- X##########################################################################
- X
- XEOF
- X
- X
- X
- Xif [ "$xenix" = "1" ]
- Xthen
- X LIBS="-ltermlib"
- Xelif [ "$sys" = "bsd" ]
- Xthen
- X LIBS="-ltermcap"
- Xelse
- X LIBS="-lcurses -ltermcap -lPW"
- Xfi
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "To build \"less\", you must link with libraries supplied by your system."
- X $ECHO "(If this needs to be changed later, edit the makefile"
- X $ECHO "and change the definition of LIBS.)"
- X $ECHO "What libraries should be used [$LIBS] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X LIBS="$ans"
- X fi
- X $ECHO ""
- Xfi
- Xcat >>makefile <<EOF
- X# LIBS is the list of libraries needed.
- XLIBS = $LIBS
- X
- XEOF
- X
- X
- X
- XINSTALL_LESS="/usr/local/bin/less"
- XINSTALL_KEY="/usr/local/bin/lesskey"
- XINSTALL_HELP="/usr/local/bin/less.help"
- XINSTALL_LESSMAN="/usr/man/man1/less.1"
- XINSTALL_KEYMAN="/usr/man/man1/lesskey.1"
- XLESS_MANUAL="less.nro"
- XKEY_MANUAL="lesskey.nro"
- Xif [ $alldefault = 0 ]
- Xthen
- X $ECHO "What is the name of the \"public\" (installed) version of less?"
- X $ECHO " [$INSTALL_LESS] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X INSTALL_LESS="$ans"
- X fi
- X $ECHO "What is the name of the \"public\" (installed) version of lesskey?"
- X $ECHO " [$INSTALL_KEY] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X INSTALL_KEY="$ans"
- X fi
- X $ECHO "What is the name of the \"public\" (installed) version of the help file?"
- X $ECHO " [$INSTALL_HELP] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X INSTALL_HELP="$ans"
- X fi
- X $ECHO "What is the name of the \"public\" (installed) version of the less manual page?"
- X $ECHO " [$INSTALL_LESSMAN] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X INSTALL_LESSMAN="$ans"
- X fi
- X $ECHO "What is the name of the \"public\" (installed) version of the lesskey manual page?"
- X $ECHO " [$INSTALL_KEYMAN] \c"
- X read ans
- X if [ "X$ans" != "X" ]
- X then
- X INSTALL_KEYMAN="$ans"
- X fi
- X $ECHO ""
- Xfi
- Xcat >>makefile <<EOF
- X# INSTALL_LESS is a list of the public versions of less.
- X# INSTALL_KEY is a list of the public versions of lesskey.
- X# INSTALL_HELP is a list of the public version of the help file.
- X# INSTALL_LESSMAN is a list of the public versions of the less manual page.
- X# INSTALL_KEYMAN is a list of the public versions of the lesskey manual page.
- XINSTALL_LESS = \$(ROOT)$INSTALL_LESS
- XINSTALL_KEY = \$(ROOT)$INSTALL_KEY
- XINSTALL_HELP = \$(ROOT)$INSTALL_HELP
- XINSTALL_LESSMAN = \$(ROOT)$INSTALL_LESSMAN
- XINSTALL_KEYMAN = \$(ROOT)$INSTALL_KEYMAN
- XLESS_MANUAL = $LESS_MANUAL
- XKEY_MANUAL = $KEY_MANUAL
- XHELPFILE = $INSTALL_HELP
- X
- X
- XEOF
- X
- X
- X
- Xcat >>makefile <<"EOF"
- X# OPTIM is passed to the compiler and the loader.
- X# It is normally "-O" but may be, for example, "-g".
- XOPTIM = -O
- X
- XCFLAGS = $(OPTIM)
- X
- X
- X
- X##########################################################################
- X# Files
- X##########################################################################
- X
- XSRC1 = main.c option.c prim.c ch.c position.c input.c linenum.c
- XSRC2 = screen.c prompt.c line.c signal.c os.c help.c ttyin.c command.c
- XSRC3 = output.c decode.c tags.c version.c
- XSRC = $(SRC1) $(SRC2) $(SRC3)
- XOBJ = main.o option.o prim.o ch.o position.o input.o output.o \
- X screen.o prompt.o line.o signal.o os.o help.o ttyin.o \
- X decode.o command.o linenum.o tags.o version.o
- X
- X
- X##########################################################################
- X# Rules for building stuff
- X##########################################################################
- X
- XEOF
- X
- Xif [ "$USERFILE" = "1" ]
- Xthen
- X cat >>makefile <<"EOF"
- Xall: less lesskey
- Xinstall: install_less install_help install_key install_lman install_kman
- XEOF
- Xelse
- X cat >>makefile <<"EOF"
- Xall: less
- Xinstall: install_less install_help install_lman
- XEOF
- Xfi
- X
- Xcat >>makefile <<"EOF"
- X
- Xless: $(OBJ)
- X $(CC) $(LDFLAGS) $(OPTIM) -o less $(OBJ) $(LIBS) $(LDLIBS)
- X
- Xlesskey: lesskey.o
- X $(CC) $(LDFLAGS) $(OPTIM) -o lesskey lesskey.o $(LDLIBS)
- X
- X# help.o depends on makefile for the definition of HELPFILE
- Xhelp.o: makefile
- X $(CC) $(CFLAGS) -c -DHELPFILE=\"$(HELPFILE)\" help.c
- X
- Xinstall_less: less
- X for f in $(INSTALL_LESS); do rm -f $$f; cp less $$f; done
- X touch install_less
- X
- Xinstall_key: lesskey
- X for f in $(INSTALL_KEY); do rm -f $$f; cp lesskey $$f; done
- X touch install_key
- X
- Xinstall_help: less.help
- X for f in $(INSTALL_HELP); do rm -f $$f; cp less.help $$f; done
- X touch install_help
- X
- Xinstall_lman: $(LESS_MANUAL)
- X for f in $(INSTALL_LESSMAN); do rm -f $$f; cp $(LESS_MANUAL) $$f; done
- X touch install_lman
- X
- Xinstall_kman: $(KEY_MANUAL)
- X for f in $(INSTALL_KEYMAN); do rm -f $$f; cp $(KEY_MANUAL) $$f; done
- X touch install_kman
- X
- X##########################################################################
- X# Maintenance
- X##########################################################################
- X
- Xlint:
- X lint -hp $(SRC)
- X
- Xnewfuncs funcs.h:
- X if [ -f funcs.h ]; then mv funcs.h funcs.h.OLD; fi
- X awk -f mkfuncs.awk $(SRC) >funcs.h
- X
- Xclean:
- X rm -f $(OBJ) lesskey.o less lesskey vecho
- X
- Xclobber:
- X rm -f *.o less lesskey vecho install_less install_key \
- X install_help install_lman install_kman
- X
- Xshar:
- X shar -v linstall less.h position.h funcs.h cmd.h \
- X vecho.c lesskey.c less.nro lesskey.nro lesskey.man > less.shar.a
- X shar -v $(SRC1) > less.shar.b
- X shar -v $(SRC2) > less.shar.c
- X shar -v $(SRC3) less.man README less.help *.awk >less.shar.d
- X
- X
- X##########################################################################
- X# Dependencies
- X##########################################################################
- X
- X$(OBJ): less.h funcs.h defines.h position.h
- Xcommand.o decode.o: cmd.h
- Xlesskey.o: less.h funcs.h defines.h cmd.h
- X
- XEOF
- X$ECHO ""
- X
- X$ECHO "The makefile has been built."
- X$ECHO "You should check it to make sure everything is as you want it to be."
- X$ECHO "When you are satisfied with the makefile, just type \"make\""
- X$ECHO "and \"less\" will be built."
- END_OF_FILE
- echo shar: Extracting \"less.h\"
- sed "s/^X//" >'less.h' <<'END_OF_FILE'
- X/*
- X * Standard include file for "less".
- X */
- X
- X/*
- X * Include the file of compile-time options.
- X */
- X#include "defines.h"
- X
- X/*
- X * Language details.
- X */
- X#if !VOID
- X#define void int
- X#endif
- X#define public /* PUBLIC FUNCTION */
- X
- X/*
- X * Special types and constants.
- X */
- Xtypedef long POSITION;
- X/*
- X * {{ Warning: if POSITION is changed to other than "long",
- X * you may have to change some of the printfs which use "%ld"
- X * to print a variable of type POSITION. }}
- X */
- X
- X#define NULL_POSITION ((POSITION)(-1))
- X
- X/*
- X * The type of signal handler functions.
- X * Usually int, although it should be void.
- X */
- Xtypedef int HANDLER;
- X
- X
- X#define FILENAME 128 /* Max size of a filename */
- X
- X#define EOI (0)
- X#ifndef NULL
- X#define NULL (0)
- X#endif
- X
- X#define READ_INTR (-2)
- X
- X/* How quiet should we be? */
- X#define NOT_QUIET 0 /* Ring bell at eof and for errors */
- X#define LITTLE_QUIET 1 /* Ring bell only for errors */
- X#define VERY_QUIET 2 /* Never ring bell */
- X
- X/* How should we prompt? */
- X#define PR_SHORT 0 /* Prompt with colon */
- X#define PR_MEDIUM 1 /* Prompt with message */
- X#define PR_LONG 2 /* Prompt with longer message */
- X
- X/* How should we handle backspaces? */
- X#define BS_SPECIAL 0 /* Do special things for underlining and bold */
- X#define BS_NORMAL 1 /* \b treated as normal char; actually output */
- X#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */
- X
- X/* Special chars used to tell put_line() to do something special */
- X#define UL_CHAR '\201' /* Enter underline mode */
- X#define UE_CHAR '\202' /* Exit underline mode */
- X#define BO_CHAR '\203' /* Enter boldface mode */
- X#define BE_CHAR '\204' /* Exit boldface mode */
- X
- X#define CONTROL(c) ((c)&037)
- X#define SIGNAL(sig,func) signal(sig,func)
- X
- X/* Library function declarations */
- Xoffset_t lseek();
- Xchar *calloc();
- X
- X#include "funcs.h"
- END_OF_FILE
- echo shar: Extracting \"position.h\"
- sed "s/^X//" >'position.h' <<'END_OF_FILE'
- X/*
- X * Include file for interfacing to position.c modules.
- X */
- X#define TOP (0)
- X#define TOP_PLUS_ONE (1)
- X#define BOTTOM (-1)
- X#define BOTTOM_PLUS_ONE (-2)
- X#define MIDDLE (-3)
- END_OF_FILE
- echo shar: Extracting \"funcs.h\"
- sed "s/^X//" >'funcs.h' <<'END_OF_FILE'
- X public void edit ();
- X public void next_file ();
- X public void prev_file ();
- X public void strtcpy ();
- X public char * save ();
- X public void quit ();
- X public void init_option ();
- X public void toggle_option ();
- X public int single_char_option ();
- X public void scan_option ();
- X public int getnum ();
- X public void forward ();
- X public void backward ();
- X public void repaint ();
- X public void jump_forw ();
- X public void jump_back ();
- X public void jump_percent ();
- X public void jump_loc ();
- X public void init_mark ();
- X public void setmark ();
- X public void lastmark ();
- X public void gomark ();
- X public int get_back_scroll ();
- X public void search ();
- X public void end_logfile ();
- X public void sync_logfile ();
- X public int ch_seek ();
- X public int ch_end_seek ();
- X public int ch_beg_seek ();
- X public POSITION ch_length ();
- X public POSITION ch_tell ();
- X public int ch_forw_get ();
- X public int ch_back_get ();
- X public void ch_init ();
- X public POSITION position ();
- X public void add_forw_pos ();
- X public void add_back_pos ();
- X public void pos_clear ();
- X public int onscreen ();
- X public POSITION forw_line ();
- X public POSITION back_line ();
- X public void clr_linenum ();
- X public void add_lnum ();
- X public int find_linenum ();
- X public int currline ();
- X public void raw_mode ();
- X public void get_term ();
- X public void init ();
- X public void deinit ();
- X public void home ();
- X public void add_line ();
- X public void lower_left ();
- X public void bell ();
- X public void vbell ();
- X public void clear ();
- X public void clear_eol ();
- X public void so_enter ();
- X public void so_exit ();
- X public void ul_enter ();
- X public void ul_exit ();
- X public void bo_enter ();
- X public void bo_exit ();
- X public void backspace ();
- X public void putbs ();
- X public void init_prompt ();
- X public char * eq_message ();
- X public char * pr_string ();
- X public void prewind ();
- X public int pappend ();
- X public POSITION forw_raw_line ();
- X public POSITION back_raw_line ();
- X public HANDLER winch ();
- X public HANDLER winch ();
- X public void init_signals ();
- X public int psignals ();
- X public void lsystem ();
- X public int iread ();
- X public void intread ();
- X public long get_time ();
- X public char * glob ();
- X public char * glob ();
- X public char * bad_file ();
- X public char * bad_file ();
- X public char * errno_message ();
- X public char * errno_message ();
- X public void help ();
- X public void open_getchr ();
- X public int getchr ();
- X public void commands ();
- X public void put_line ();
- X public int control_char ();
- X public int carat_char ();
- X public void flush ();
- X public void dropout ();
- X public void putchr ();
- X public void putstr ();
- X public void error ();
- X public void ierror ();
- X public int cmd_decode ();
- X public void noprefix ();
- X public void init_cmd ();
- X public int findtag ();
- X public int tagsearch ();
- END_OF_FILE
- echo shar: Extracting \"cmd.h\"
- sed "s/^X//" >'cmd.h' <<'END_OF_FILE'
- X#define MAX_USERCMD 200
- X#define MAX_CMDLEN 16
- X
- X#define A_AGAIN_SEARCH 1
- X#define A_B_LINE 2
- X#define A_B_SCREEN 3
- X#define A_B_SCROLL 4
- X#define A_B_SEARCH 5
- X#define A_DIGIT 6
- X#define A_DISP_OPTION 7
- X#define A_DEBUG 8
- X#define A_EXAMINE 9
- X#define A_FIRSTCMD 10
- X#define A_FREPAINT 11
- X#define A_F_LINE 12
- X#define A_F_SCREEN 13
- X#define A_F_SCROLL 14
- X#define A_F_SEARCH 15
- X#define A_GOEND 16
- X#define A_GOLINE 17
- X#define A_GOMARK 18
- X#define A_HELP 19
- X#define A_NEXT_FILE 20
- X#define A_PERCENT 21
- X#define A_PREFIX 22
- X#define A_PREV_FILE 23
- X#define A_QUIT 24
- X#define A_REPAINT 25
- X#define A_SETMARK 26
- X#define A_SHELL 27
- X#define A_STAT 28
- X
- X#define A_TOGGLE_OPTION 30
- X#define A_VERSION 31
- X#define A_VISUAL 32
- X
- X#define A_INVALID 100
- X#define A_NOACTION 101
- END_OF_FILE
- echo shar: Extracting \"vecho.c\"
- sed "s/^X//" >'vecho.c' <<'END_OF_FILE'
- X/*
- X * This dumb little program emulates the System V "echo" command,
- X * to accomodate BSD systems which don't understand the \c escape,
- X * meaning don't echo a newline. BSD uses "echo -n".
- X */
- X
- X#include <stdio.h>
- X
- Xint putnl;
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X putnl = 1;
- X while (--argc > 0)
- X {
- X vecho(*++argv);
- X if (argc > 1)
- X putchar(' ');
- X }
- X if (putnl)
- X putchar('\n');
- X}
- X
- Xvecho(str)
- X char *str;
- X{
- X register char *s;
- X
- X for (s = str; *s != '\0'; s++)
- X {
- X if (*s == '\\' && s[1] == 'c')
- X {
- X putnl = 0;
- X return;
- X }
- X putchar(*s);
- X }
- X}
- END_OF_FILE
- echo shar: Extracting \"lesskey.c\"
- sed "s/^X//" >'lesskey.c' <<'END_OF_FILE'
- X/*
- X * lesskey [-o output] [input]
- X *
- X * Make a .less file.
- X * If no input file is specified, standard input is used.
- X * If no output file is specified, $HOME/.less is used.
- X *
- X * The .less file is used to specify (to "less") user-defined
- X * key bindings. Basically any sequence of 1 to MAX_CMDLEN
- X * keystrokes may be bound to an existing less function.
- X *
- X * The input file is an ascii file consisting of a
- X * sequence of lines of the form:
- X * string <whitespace> action <newline>
- X *
- X * "string" is a sequence of command characters which form
- X * the new user-defined command. The command
- X * characters may be:
- X * 1. The actual character itself.
- X * 2. A character preceeded by ^ to specify a
- X * control character (e.g. ^X means control-X).
- X * 3. Any character (other than an octal digit) preceeded by
- X * a \ to specify the character itself (characters which
- X * must be preceeded by \ include ^, \, and whitespace.
- X * 4. A backslash followed by one to three octal digits
- X * to specify a character by its octal value.
- X * "action" is the name of a "less" action, from the table below.
- X *
- X * Blank lines and lines which start with # are ignored.
- X *
- X *
- X * The output file is a non-ascii file, consisting of
- X * zero or more byte sequences of the form:
- X * string <0> <action>
- X *
- X * "string" is the command string.
- X * "<0>" is one null byte.
- X * "<action>" is one byte containing the action code (the A_xxx value).
- X *
- X *
- X * Revision history
- X *
- X * v1: Initial version. 10/13/87 mark
- X */
- X
- X#include <stdio.h>
- X#include "less.h"
- X#include "cmd.h"
- X
- Xchar usertable[MAX_USERCMD];
- X
- Xstruct cmdname
- X{
- X char *cn_name;
- X int cn_action;
- X} cmdnames[] =
- X{
- X "back-line", A_B_LINE,
- X "back-screen", A_B_SCREEN,
- X "back-scroll", A_B_SCROLL,
- X "back-search", A_B_SEARCH,
- X "debug", A_DEBUG,
- X "display-flag", A_DISP_OPTION,
- X "display-option", A_DISP_OPTION,
- X "end", A_GOEND,
- X "examine", A_EXAMINE,
- X "first-cmd", A_FIRSTCMD,
- X "firstcmd", A_FIRSTCMD,
- X "flush-repaint", A_FREPAINT,
- X "forw-line", A_F_LINE,
- X "forw-screen", A_F_SCREEN,
- X "forw-scroll", A_F_SCROLL,
- X "forw-search", A_F_SEARCH,
- X "goto-end", A_GOEND,
- X "goto-line", A_GOLINE,
- X "goto-mark", A_GOMARK,
- X "help", A_HELP,
- X "invalid", A_NOACTION,
- X "next-file", A_NEXT_FILE,
- X "noaction", A_NOACTION,
- X "percent", A_PERCENT,
- X "prev-file", A_PREV_FILE,
- X "quit", A_QUIT,
- X "repaint", A_REPAINT,
- X "repaint-flush", A_FREPAINT,
- X "repeat-search", A_AGAIN_SEARCH,
- X "set-mark", A_SETMARK,
- X "shell", A_SHELL,
- X "status", A_STAT,
- X "toggle-flag", A_TOGGLE_OPTION,
- X "toggle-option", A_TOGGLE_OPTION,
- X "version", A_VERSION,
- X "visual", A_VISUAL,
- X NULL, 0
- X};
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X char *p; /* {{ Can't be register since we use &p }} */
- X register char *up; /* Pointer into usertable */
- X FILE *desc; /* Description file (input) */
- X FILE *out; /* Output file */
- X int linenum; /* Line number in input file */
- X char *currcmd; /* Start of current command string */
- X int errors;
- X int i;
- X char line[100];
- X char *outfile;
- X
- X extern char *getenv();
- X
- X /*
- X * Process command line arguments.
- X */
- X outfile = NULL;
- X while (--argc > 0 && **(++argv) == '-')
- X {
- X switch (argv[0][1])
- X {
- X case 'o':
- X outfile = &argv[0][2];
- X if (*outfile == '\0')
- X {
- X if (--argc <= 0)
- X usage();
- X outfile = *(++argv);
- X }
- X break;
- X default:
- X usage();
- X }
- X }
- X if (argc > 1)
- X usage();
- X
- X
- X /*
- X * Open the input file, or use standard input if none specified.
- X */
- X if (argc > 0)
- X {
- X if ((desc = fopen(*argv, "r")) == NULL)
- X {
- X perror(*argv);
- X exit(1);
- X }
- X } else
- X desc = stdin;
- X
- X /*
- X * Read the input file, one line at a time.
- X * Each line consists of a command string,
- X * followed by white space, followed by an action name.
- X */
- X linenum = 0;
- X errors = 0;
- X up = usertable;
- X while (fgets(line, sizeof(line), desc) != NULL)
- X {
- X ++linenum;
- X
- X /*
- X * Skip leading white space.
- X * Replace the final newline with a null byte.
- X * Ignore blank lines and comment lines.
- X */
- X p = line;
- X while (*p == ' ' || *p == '\t')
- X ++p;
- X for (i = 0; p[i] != '\n' && p[i] != '\0'; i++)
- X ;
- X p[i] = '\0';
- X if (*p == '#' || *p == '\0')
- X continue;
- X
- X /*
- X * Parse the command string and store it in the usertable.
- X */
- X currcmd = up;
- X do
- X {
- X if (up >= usertable + MAX_USERCMD)
- X {
- X fprintf(stderr, "too many commands, line %d\n",
- X linenum);
- X exit(1);
- X }
- X if (up >= currcmd + MAX_CMDLEN)
- X {
- X fprintf(stderr, "command too long on line %d\n",
- X linenum);
- X errors++;
- X break;
- X }
- X
- X *up++ = tchar(&p);
- X
- X } while (*p != ' ' && *p != '\t' && *p != '\0');
- X
- X /*
- X * Terminate the command string with a null byte.
- X */
- X *up++ = '\0';
- X
- X /*
- X * Skip white space between the command string
- X * and the action name.
- X * Terminate the action name if it is followed
- X * by whitespace or a # comment.
- X */
- X if (*p == '\0')
- X {
- X fprintf(stderr, "missing whitespace on line %d\n",
- X linenum);
- X errors++;
- X continue;
- X }
- X while (*p == ' ' || *p == '\t')
- X ++p;
- X for (i = 0; p[i] != ' ' && p[i] != '\t' &&
- X p[i] != '#' && p[i] != '\0'; i++)
- X ;
- X p[i] = '\0';
- X
- X /*
- X * Parse the action name and store it in the usertable.
- X */
- X for (i = 0; cmdnames[i].cn_name != NULL; i++)
- X if (strcmp(cmdnames[i].cn_name, p) == 0)
- X break;
- X if (cmdnames[i].cn_name == NULL)
- X {
- X fprintf(stderr, "unknown action <%s> on line %d\n",
- X p, linenum);
- X errors++;
- X continue;
- X }
- X *up++ = cmdnames[i].cn_action;
- X }
- X
- X if (errors > 0)
- X {
- X fprintf(stderr, "%d errors; no output produced\n", errors);
- X exit(1);
- X }
- X
- X /*
- X * Write the output file.
- X * If no output file was specified, use "$HOME/.less"
- X */
- X if (outfile == NULL)
- X {
- X p = getenv("HOME");
- X if (p == NULL)
- X {
- X fprintf(stderr, "cannot find $HOME\n");
- X exit(1);
- X }
- X strcpy(line, p);
- X strcat(line, "/.less");
- X outfile = line;
- X }
- X if ((out = fopen(outfile, "w")) == NULL)
- X perror(outfile);
- X else
- X fwrite((char *)usertable, 1, up-usertable, out);
- X}
- X
- X/*
- X * Parse one character of the command string.
- X */
- Xtchar(pp)
- X char **pp;
- X{
- X register char *p;
- X register char ch;
- X register int i;
- X
- X p = *pp;
- X switch (*p)
- X {
- X case '\\':
- X if (*++p >= '0' && *p <= '7')
- X {
- X /*
- X * Parse an octal number.
- X */
- X ch = 0;
- X i = 0;
- X do
- X ch = 8*ch + (*p - '0');
- X while (*++p >= '0' && *p <= '7' && ++i < 3);
- X *pp = p;
- X return (ch);
- X }
- X /*
- X * Backslash followed by a char just means that char.
- X */
- X *pp = p+1;
- X return (*p);
- X case '^':
- X /*
- X * Carat means CONTROL.
- X */
- X *pp = p+2;
- X return (CONTROL(p[1]));
- X }
- X *pp = p+1;
- X return (*p);
- X}
- X
- Xusage()
- X{
- X fprintf(stderr, "usage: lesskey [-o output] [input]\n");
- X exit(1);
- X}
- END_OF_FILE
- echo shar: Extracting \"less.nro\"
- sed "s/^X//" >'less.nro' <<'END_OF_FILE'
- X.TH LESS 1
- X.SH NAME
- Xless \- opposite of more
- X.SH SYNOPSIS
- X.B "less [-[+]aABcCdeEimMnqQuUsw] [-b\fIN\fB] [-h\fIN\fB] [-x\fIN\fB] [-[z]\fIN\fB]"
- X.br
- X.B " [-P[mM=]\fIstring\fB] [-[lL]\fIlogfile\fB] [+\fIcmd\fB]"
- X.br
- X.B " [-t\fItag\fB] [\fIfilename\fB]..."
- X.SH DESCRIPTION
- X.I Less
- Xis a program similar to
- X.I more
- X(1), but which allows backwards movement
- Xin the file as well as forward movement.
- XAlso,
- X.I less
- Xdoes not have to read the entire input file before starting,
- Xso with large input files it starts up faster than text editors like
- X.I vi
- X(1).
- X.I Less
- Xuses termcap (or terminfo on some systems),
- Xso it can run on a variety of terminals.
- XThere is even limited support for hardcopy terminals.
- X(On a hardcopy terminal, lines which should be printed at the top
- Xof the screen are prefixed with an up-arrow.)
- X.PP
- XCommands are based on both
- X.I more
- Xand
- X.I vi.
- XCommands may be preceeded by a decimal number,
- Xcalled N in the descriptions below.
- XThe number is used by some commands, as indicated.
- X
- X.SH COMMANDS
- XIn the following descriptions, ^X means control-X.
- XESC stands for the ESCAPE key; for example ESC-v means the
- Xtwo character sequence "ESCAPE", then "v".
- X.IP H
- XHelp: display a summary of these commands.
- XIf you forget all the other commands, remember this one.
- X.PP
- X.IP "SPACE or f or ^F or ^V"
- XScroll forward N lines, default one window (see option -z below).
- XIf N is more than the screen size, only the final screenful is displayed.
- XWarning: some systems use ^V as a special literalization character.
- X.PP
- X.IP "b or ^B or ESC-v"
- XScroll backward N lines, default one window (see option -z below).
- XIf N is more than the screen size, only the final screenful is displayed.
- X.PP
- X.IP "RETURN or ^N or e or ^E or j or ^J"
- XScroll forward N lines, default 1.
- XThe entire N lines are displayed, even if N is more than the screen size.
- X.PP
- X.IP "y or ^Y or ^P or k or ^K"
- XScroll backward N lines, default 1.
- XThe entire N lines are displayed, even if N is more than the screen size.
- XWarning: some systems use ^Y as a special job control character.
- X.PP
- X.IP "d or ^D"
- XScroll forward N lines, default one half of the screen size.
- XIf N is specified, it becomes the new default for
- Xsubsequent d and u commands.
- X.PP
- X.IP "u or ^U"
- XScroll backward N lines, default one half of the screen size.
- XIf N is specified, it becomes the new default for
- Xsubsequent d and u commands.
- X.PP
- X.IP "r or ^R or ^L"
- XRepaint the screen.
- X.PP
- X.IP R
- XRepaint the screen, discarding any buffered input.
- XUseful if the file is changing while it is being viewed.
- X.PP
- X.IP "g or < or ESC-<"
- XGo to line N in the file, default 1 (beginning of file).
- X(Warning: this may be slow if N is large.)
- X.PP
- X.IP "G or > or ESC->"
- XGo to line N in the file, default the end of the file.
- X(Warning: this may be slow if N is large,
- Xor if N is not specified and
- Xstandard input, rather than a file, is being read.)
- X.PP
- X.IP "p or %"
- XGo to a position N percent into the file.
- XN should be between 0 and 100.
- X(This works if standard input is being read, but only if
- X.I less
- Xhas already read to the end of the file.
- XIt is always fast, but not always useful.)
- X.PP
- X.IP m
- XFollowed by any lowercase letter,
- Xmarks the current position with that letter.
- X.PP
- X.IP "'"
- X(Single quote.)
- XFollowed by any lowercase letter, returns to the position which
- Xwas previously marked with that letter.
- XFollowed by another single quote, returns to the postion at
- Xwhich the last "large" movement command was executed.
- XAll marks are lost when a new file is examined.
- X.PP
- X.IP "^X^X"
- XSame as single quote.
- X.PP
- X.IP /pattern
- XSearch forward in the file for the N-th line containing the pattern.
- XN defaults to 1.
- XThe pattern is a regular expression, as recognized by
- X.I ed.
- XThe search starts at the second line displayed
- X(but see the -a option, which changes this).
- X.PP
- X.IP ?pattern
- XSearch backward in the file for the N-th line containing the pattern.
- XThe search starts at the line immediately before the top line displayed.
- X.PP
- X.IP /!pattern
- XLike /, but the search is for the N-th line
- Xwhich does NOT contain the pattern.
- X.PP
- X.IP ?!pattern
- XLike ?, but the search is for the N-th line
- Xwhich does NOT contain the pattern.
- X.PP
- X.IP n
- XRepeat previous search, for N-th line containing the last pattern
- X(or NOT containing the last pattern, if the previous search
- Xwas /! or ?!).
- X.PP
- X.IP "E [filename]"
- XExamine a new file.
- XIf the filename is missing, the "current" file (see the N and P commands
- Xbelow) from the list of files in the command line is re-examined.
- XIf the filename is a pound sign (#), the previously examined file is
- Xre-examined.
- X.PP
- X.IP "^X^V or :e"
- XSame as E.
- XWarning: some systems use ^V as a special literalization character.
- X.PP
- X.IP "N or :n"
- XExamine the next file (from the list of files given in the command line).
- XIf a number N is specified (not to be confused with the command N),
- Xthe N-th next file is examined.
- X.PP
- X.IP "P or :p"
- XExamine the previous file.
- XIf a number N is specified, the N-th previous file is examined.
- X.PP
- X.IP "= or ^G"
- XPrints some information about the file being viewed,
- Xincluding its name
- Xand the line number and byte offset of the bottom line being displayed.
- XIf possible, it also prints the length of the file
- Xand the percent of the file above the last displayed line.
- X.PP
- X.IP \-
- XFollowed by one of the command line option letters (see below),
- Xthis will change the setting of that option
- Xand print a message describing the new setting.
- XIf the option letter has a numeric value (such as -b or -h),
- Xor a string value (such as -P or -t),
- Xa new value may be entered after the option letter.
- X.PP
- X.IP \_
- X(Underscore.)
- XFollowed by one of the command line option letters (see below),
- Xthis will print a message describing the current setting of that option.
- XThe setting of the option is not changed.
- X.PP
- X.IP +cmd
- XCauses the specified cmd to be executed each time a new file is examined.
- XFor example, +G causes
- X.I less
- Xto initially display each file starting at the end
- Xrather than the beginning.
- X.PP
- X.IP V
- XPrints the version number of
- X.I less
- Xbeing run.
- X.PP
- X.IP "q or :q or ZZ"
- XExits
- X.I less.
- X.PP
- XThe following
- Xtwo
- Xcommands may or may not be valid, depending on your particular installation.
- X.PP
- X.IP v
- XInvokes an editor to edit the current file being viewed.
- XThe editor is taken from the environment variable EDITOR,
- Xor defaults to "vi".
- X.PP
- X.IP "! shell-command"
- XInvokes a shell to run the shell-command given.
- XA percent sign in the command is replaced by the name of the
- Xcurrent file. "!!" repeats the last shell command.
- X"!" with no shell command simply invokes a shell.
- XIn all cases, the shell is taken from the environment variable SHELL,
- Xor defaults to "sh".
- X.PP
- X.SH OPTIONS
- XCommand line options are described below.
- XMost options may be changed while
- X.I less
- Xis running, via the "\-" command.
- X.PP
- XOptions are also taken from the environment variable "LESS".
- XFor example,
- Xto avoid typing "less -options ..." each time
- X.I less
- Xis invoked, you might tell
- X.I csh:
- X.sp
- Xsetenv LESS "-options"
- X.sp
- Xor if you use
- X.I sh:
- X.sp
- XLESS="-options"; export LESS
- X.sp
- XThe environment variable is parsed before the command line,
- Xso command line options override the LESS environment variable.
- XIf an option appears in the LESS variable, it can be reset
- Xto its default on the command line by beginning the command
- Xline option with "-+".
- X.sp
- XA dollar sign ($) may be used to signal the end of an option string.
- XThis is important only for options like -P which take a
- Xfollowing string.
- X.IP -a
- XNormally, forward searches start just after
- Xthe top displayed line (that is, at the second displayed line).
- XThus, forward searches include the currently displayed screen.
- XThe -a option causes forward searches to start
- Xjust after the bottom line displayed,
- Xthus skipping the currently displayed screen.
- X.IP -A
- XThe -A option causes searches to start at the second SCREEN line
- Xdisplayed, as opposed to the default which is to start at the second
- XREAL line displayed.
- XFor example, suppose a long real line occupies the first three screen lines.
- XThe default search will start at the second real line (the fourth
- Xscreen line), while the -A option
- Xwill cause the search to start at the second screen line (in the
- Xmidst of the first real line).
- X(This option is rarely useful.)
- X.IP -b
- XThe -b\fIn\fR option tells
- X.I less
- Xto use a non-standard number of buffers.
- XBuffers are 1K, and normally 10 buffers are used
- X(except if data in coming from standard input; see the -B option).
- XThe number \fIn\fR specifies a different number of buffers to use.
- X.IP -B
- XNormally, when data is coming from standard input,
- Xbuffers are allocated automatically as needed, to avoid loss of data.
- XThe -B option disables this feature, so that only the default number
- Xof buffers are used.
- XIf more data is read than will fit in the buffers, the oldest
- Xdata is discarded.
- X.IP -c
- XNormally,
- X.I less
- Xwill repaint the screen by scrolling from the bottom of the screen.
- XIf the -c option is set, when
- X.I less
- Xneeds to change the entire display, it will paint from the top line down.
- X.IP -C
- XThe -C option is like -c, but the screen is cleared before it is repainted.
- X.IP -d
- XNormally,
- X.I less
- Xwill complain if the terminal is dumb; that is, lacks some important capability,
- Xsuch as the ability to clear the screen or scroll backwards.
- XThe -d option suppresses this complaint
- X(but does not otherwise change the behavior of the program on a dumb terminal).
- X.IP -e
- XNormally the only way to exit less is via the "q" command.
- XThe -e option tells less to automatically exit
- Xthe second time it reaches end-of-file.
- X.IP -E
- XThe -E flag causes less to exit the first time it reaches end-of-file.
- X.IP -h
- XNormally,
- X.I less
- Xwill scroll backwards when backwards movement is necessary.
- XThe -h option specifies a maximum number of lines to scroll backwards.
- XIf it is necessary to move backwards more than this many lines,
- Xthe screen is repainted in a forward direction.
- X(If the terminal does not have the ability to scroll
- Xbackwards, -h0 is implied.)
- X.IP -i
- XThe -i option causes searches to ignore case; that is,
- Xuppercase and lowercase are considered identical.
- XAlso, text which is overstruck or underlined can be searched for.
- X.IP -l
- XThe -l option, followed immediately by a filename,
- Xwill cause
- X.I less
- Xto copy its input to the named file as it is being viewed.
- XThis applies only when the input file is a pipe,
- Xnot an ordinary file.
- XIf the file already exists, less will ask for confirmation before
- Xoverwriting it.
- X.IP -L
- XThe -L option is like -l, but it will overwrite an existing
- Xfile without asking for confirmation.
- X.sp
- XIf no log file has been specified,
- Xthe -l and -L options can be used from within less to specify a log file.
- XWithout a file name, they will simply report the name of the log file.
- X.IP -m
- XNormally,
- X.I less
- Xprompts with a colon.
- XThe -m option causes
- X.I less
- Xto prompt verbosely (like
- X.I more),
- Xwith the percent into the file.
- X.IP -M
- XThe -M option causes
- X.I less
- Xto prompt even more verbosely than
- X.I more.
- X.IP -n
- XThe -n flag suppresses line numbers.
- XThe default (to use line numbers) may cause
- X.I less
- Xto run more slowly in some cases, especially with a very large input file.
- XSuppressing line numbers with the -n flag will avoid this problem.
- XUsing line numbers means: the line number will be displayed in the verbose
- Xprompt and in the = command,
- Xand the v command will pass the current line number to the editor.
- X.IP -P
- XThe -P option provides a way to tailor the three prompt
- Xstyles to your own preference.
- XYou would normally put this option in your LESS environment
- Xvariable, rather than type it in with each less command.
- XSuch an option must either be the last option in the LESS variable,
- Xor be terminated by a dollar sign.
- X-P followed by a string changes the default (short) prompt to that string.
- X-Pm changes the medium (-m) prompt to the string, and
- X-PM changes the long (-M) prompt.
- XAlso, -P= changes the message printed by the = command to the given string.
- XAll prompt strings consist of a sequence of
- Xletters and special escape sequences.
- XSee the section on PROMPTS for more details.
- X.IP -q
- XNormally, if an attempt is made to scroll past the end of the file
- Xor before the beginning of the file, the terminal bell is rung to
- Xindicate this fact.
- XThe -q option tells
- X.I less
- Xnot to ring the bell at such times.
- XIf the terminal has a "visual bell", it is used instead.
- X.IP -Q
- XEven if -q is given,
- X.I less
- Xwill ring the bell on certain other errors,
- Xsuch as typing an invalid character.
- XThe -Q option tells
- X.I less
- Xto be quiet all the time; that is, never ring the terminal bell.
- XIf the terminal has a "visual bell", it is used instead.
- X.IP -s
- XThe -s option causes
- Xconsecutive blank lines to be squeezed into a single blank line.
- XThis is useful when viewing
- X.I nroff
- Xoutput.
- X.IP -t
- XThe -t option, followed immediately by a TAG,
- Xwill edit the file containing that tag.
- XFor this to work, there must be a file called "tags" in the
- Xcurrent directory, which was previously built by the
- X.I ctags
- X(1) command.
- XThis option may also be specified from within less
- X(using the \- command) as a way of examining a new file.
- X.IP -u
- XIf the -u option is given,
- Xbackspaces are treated as printable characters;
- Xthat is, they are sent to the terminal when they appear in the input.
- X.IP -U
- XIf the -U option is given,
- Xbackspaces are printed as the two character sequence "^H".
- X.sp
- XIf neither -u nor -U is given,
- Xbackspaces which appear adjacent to an underscore character
- Xare treated specially:
- Xthe underlined text is displayed
- Xusing the terminal's hardware underlining capability.
- XAlso, backspaces which appear between two identical characters
- Xare treated specially:
- Xthe overstruck text is printed
- Xusing the terminal's hardware boldface capability.
- XOther backspaces are deleted, along with the preceeding character.
- X.IP -w
- XNormally,
- X.I less
- Xuses a tilde character to represent lines past the end of the file.
- XThe -w option causes blank lines to be used instead.
- X.IP -x
- XThe -x\fIn\fR option sets tab stops every \fIn\fR positions.
- XThe default for \fIn\fR is 8.
- X.IP -[z]
- XWhen given a backwards or forwards window command,
- X.I less
- Xwill by
- Xdefault scroll backwards or forwards one screenful of lines.
- XThe -z\fIn\fR option changes the default scrolling window size
- Xto \fIn\fR lines.
- XNote that the "z" is optional for compatibility with
- X.I more.
- X.IP +
- XIf a command line option begins with \fB+\fR,
- Xthe remainder of that option is taken to be an initial command to
- X.I less.
- XFor example, +G tells
- X.I less
- Xto start at the end of the file rather than the beginning,
- Xand +/xyz tells it to start at the first occurence of "xyz" in the file.
- XAs a special case, +<number> acts like +<number>g;
- Xthat is, it starts the display at the specified line number
- X(however, see the caveat under the "g" command above).
- XIf the option starts with \fB++\fR, the initial command applies to
- Xevery file being viewed, not just the first one.
- XThe + command described previously
- Xmay also be used to set (or change) an initial command for every file.
- X
- X.SH "KEY BINDINGS"
- XYou may define your own less commands by using the program
- X.I lesskey
- X(1)
- Xto create a file called ".less" in your home directory.
- XThis file specifies a set of command keys and an action
- Xassociated with each key.
- XSee the
- X.I lesskey
- Xmanual page for more details.
- X
- X.SH "PROMPTS"
- XThe -P option allows you to tailor the prompt to your preference.
- XThe string given to the -P option replaces the specified prompt string.
- XCertain characters in the string are interpreted specially.
- XThe prompt mechanism is rather complicated to provide flexibility,
- Xbut the ordinary user need not understand the details of constructing
- Xpersonalized prompt strings.
- X.sp
- XA percent sign followed by a single character is expanded
- Xaccording to what the following character is:
- X.IP "%bX"
- XReplaced by the byte offset into the current input file.
- XThe b is followed by a single character (shown as X above)
- Xwhich specifies the line whose byte offset is to be used.
- XIf the character is a "t", the byte offset of the top line in the
- Xdisplay is used,
- Xan "m" means use the middle line,
- Xa "b" means use the bottom line,
- Xand a "B" means use the line just after the bottom line.
- X.IP "%f"
- XReplaced by the name of the current input file.
- X.IP "%i"
- XReplaced by the index of the current file in the list of
- Xinput files.
- X.IP "%lX"
- XReplaced by the line number of a line in the input file.
- XThe line to be used is determined by the X, as with the %b option.
- X.IP "%m"
- XReplaced by the total number of input files.
- X.IP "%pX"
- XReplaced by the percent into the current input file.
- XThe line used is determined by the X as with the %b option.
- X.IP "%s"
- XReplaced by the size of the current input file.
- X.IP "%t"
- XCauses any trailing spaces to be removed.
- XUsually used at the end of the string, but may appear anywhere.
- X.IP "%x"
- XReplaced by the name of the next input file in the list.
- X.PP
- XIf any item is unknown (for example, the file size if input
- Xis a pipe), a question mark is printed instead.
- X.PP
- XThe format of the prompt string can be changed
- Xdepending on certain conditions.
- XA question mark followed by a single character acts like an "IF":
- Xdepending on the following character, a condition is evaluated.
- XIf the condition is true, any characters following the question mark
- Xand condition character, up to a period, are included in the prompt.
- XIf the condition is false, such characters are not included.
- XA colon appearing between the question mark and the
- Xperiod can be used to establish an "ELSE": any characters between
- Xthe colon and the period are included in the string if and only if
- Xthe IF condition is false.
- XCondition characters (which follow a question mark) may be:
- X.IP "?a"
- XTrue if any characters have been included in the prompt so far.
- X.IP "?bX"
- XTrue if the byte offset of the specified line is known.
- X.IP "?e"
- XTrue if at end-of-file.
- X.IP "?f"
- XTrue if there is an input filename
- X(that is, if input is not a pipe).
- X.IP "?lX"
- XTrue if the line number of the specified line is known.
- X.IP "?m"
- XTrue if there is more than one input file.
- X.IP "?n"
- XTrue if this is the first prompt in a new input file.
- X.IP "?pX"
- XTrue if the percent into the current input file
- Xof the specified line is known.
- X.IP "?s"
- XTrue if the size of current input file is known.
- X.IP "?x"
- XTrue if there is a next input file
- X(that is, if the current input file is not the last one).
- X.PP
- XAny characters other than the special ones
- X(question mark, colon, period, percent, and backslash)
- Xbecome literally part of the prompt.
- XAny of the special characters may be included in the prompt literally
- Xby preceeding it with a backslash.
- X.PP
- XSome examples:
- X.sp
- X?f%f:Standard input.
- X.sp
- XThis prompt prints the filename, if known;
- Xotherwise the string "Standard input".
- X.sp
- X?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
- X.sp
- XThis prompt would print the filename, if known.
- XThe filename is followed by the line number, if known,
- Xotherwise the percent if known, otherwise the byte offset if known.
- XOtherwise, a dash is printed.
- XNotice how each question mark has a matching period,
- Xand how the % after the %pt
- Xis included literally by escaping it with a backslash.
- X.sp
- X?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
- X.sp
- XThis prints the filename if this is the first prompt in a file,
- Xfollowed by the "file N of N" message if there is more
- Xthan one input file.
- XThen, if we are at end-of-file, the string "(END)" is printed
- Xfollowed by the name of the next file, if there is one.
- XFinally, any trailing spaces are truncated.
- XThis is the default prompt.
- XFor reference, here are the defaults for
- Xthe other two prompts (-m and -M respectively).
- XEach is broken into two lines here for readability only.
- X.nf
- X.sp
- X?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
- X ?pB%pB\\%:byte\ %bB?s/%s...%t
- X.sp
- X?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt\ :byte\ %bB?s/%s\ ..
- X ?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
- X.sp
- X.fi
- XAnd here is the default message produced by the = command:
- X.nf
- X.sp
- X?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt\ .
- X byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
- X.fi
- X
- X.SH "SEE ALSO"
- Xlesskey(1)
- X
- X.SH WARNINGS
- XThe = command and prompts (unless changed by -P)
- Xreport the line number of the line at the top of the screen,
- Xbut the byte and percent of the line at the bottom of the screen.
- END_OF_FILE
- echo shar: Extracting \"lesskey.nro\"
- sed "s/^X//" >'lesskey.nro' <<'END_OF_FILE'
- X.TH LESSKEY 1
- X.SH NAME
- Xlesskey \- specify key bindings for less
- X.SH SYNOPSIS
- X.B "lesskey [-o output] [input]"
- X.SH DESCRIPTION
- X.I Lesskey
- Xis used to specify a set of key bindings to be used by
- X.I less.
- XThe input file is a text file which describes the key bindings,
- Xand the output file is a binary file which is used by
- X.I less.
- XIf no input file is specified, standard input is used.
- XIf no output file is specified, $HOME/.less is used.
- X.PP
- XThe input file consists of lines of the form:
- X.sp
- X string <whitespace> action <newline>
- X.sp
- XWhitespace is any sequence of one or more spaces and/or tabs.
- XThe "string" is the command key(s) which invoke the action.
- XThe string may be a single command key, or a sequence of up to 15 keys.
- XThe "action" is the name of the less action, from the list below.
- XThe characters in the "string" may appear literally, or be
- Xprefixed by a carat to indicate a control key.
- XA backslash may be used to cause the following character
- Xto be taken literally.
- XCharacters which must be preceeded by backslash include
- Xcarat, space, tab and the backslash itself.
- XA backslash followed by one to three octal digits may be used to
- Xspecify a character by its octal value.
- XBlank lines and lines which start with a pound sign (#) are ignored.
- X.PP
- XAs an example, the following input file describes the set of
- Xdefault command keys used by less:
- X.sp
- X.nf
- X k back-line
- X y back-line
- X ^K back-line
- X ^Y back-line
- X ^P back-line
- X b back-screen
- X ^B back-screen
- X \\33v back-screen
- X u back-scroll
- X ^U back-scroll
- X ? back-search
- X E examine
- X ^X^V examine
- X + first-cmd
- X e forw-line
- X j forw-line
- X ^E forw-line
- X ^J forw-line
- X ^M forw-line
- X ^N forw-line
- X f forw-screen
- X ^F forw-screen
- X \\40 forw-screen
- X ^V forw-screen
- X d forw-scroll
- X ^D forw-scroll
- X / forw-search
- X G goto-end
- X > goto-end
- X \\33> goto-end
- X g goto-line
- X < goto-line
- X \\33< goto-line
- X ' goto-mark
- X ^X^X goto-mark
- X H help
- X N next-file
- X % percent
- X p percent
- X P prev-file
- X q quit
- X ZZ quit
- X ^L repaint
- X ^R repaint
- X r repaint
- X R flush-repaint
- X n repeat-search
- X m set-mark
- X ! shell
- X = status
- X ^G status
- X - toggle-option
- X _ display-option
- X V version
- X v visual
- X.fi
- X.sp
- XCommands specified by
- X.I lesskey
- Xtake precedence over the default commands.
- XA default command key may be disabled by including it in the
- Xkey file with the action "invalid".
- X
- X.SH "SEE ALSO"
- Xless(1)
- END_OF_FILE
- echo shar: Extracting \"lesskey.man\"
- sed "s/^X//" >'lesskey.man' <<'END_OF_FILE'
- X
- X
- X
- X LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111))))
- X
- X
- X
- X NNNNAAAAMMMMEEEE
- X lesskey - specify key bindings for less
- X
- X SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- X lllleeeesssssssskkkkeeeeyyyy [[[[----oooo oooouuuuttttppppuuuutttt]]]] [[[[iiiinnnnppppuuuutttt]]]]
- X
- X DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- X _L_e_s_s_k_e_y is used to specify a set of key bindings to be used
- X by _l_e_s_s. The input file is a text file which describes the
- X key bindings, and the output file is a binary file which is
- X used by _l_e_s_s. If no input file is specified, standard input
- X is used. If no output file is specified, $HOME/.less is
- X used.
- X
- X The input file consists of lines of the form:
- X
- X string <whitespace> action <newline>
- X
- X Whitespace is any sequence of one or more spaces and/or
- X tabs. The "string" is the command key(s) which invoke the
- X action. The string may be a single command key, or a
- X sequence of up to 15 keys. The "action" is the name of the
- X less action, from the list below. The characters in the
- X "string" may appear literally, or be prefixed by a carat to
- X indicate a control key. A backslash may be used to cause
- X the following character to be taken literally. Characters
- X which must be preceeded by backslash include carat, space,
- X tab and the backslash itself. A backslash followed by one
- X to three octal digits may be used to specify a character by
- X its octal value. Blank lines and lines which start with a
- X pound sign (#) are ignored.
- X
- X As an example, the following input file describes the set of
- X default command keys used by less:
- X
- X k back-line
- X y back-line
- X ^K back-line
- X ^Y back-line
- X ^P back-line
- X b back-screen
- X ^B back-screen
- X \33v back-screen
- X u back-scroll
- X ^U back-scroll
- X ? back-search
- X E examine
- X ^X^V examine
- X + first-cmd
- X e forw-line
- X j forw-line
- X ^E forw-line
- X
- X
- X
- X Page 1 (printed 7/19/88)
- X
- X
- X
- X
- X
- X
- X LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111)))) UUUUNNNNIIIIXXXX 5555....0000 LLLLEEEESSSSSSSSKKKKEEEEYYYY((((1111))))
- X
- X
- X
- X ^J forw-line
- X ^M forw-line
- X ^N forw-line
- X f forw-screen
- X ^F forw-screen
- X \40 forw-screen
- X ^V forw-screen
- X d forw-scroll
- X ^D forw-scroll
- X / forw-search
- X G goto-end
- X > goto-end
- X \33> goto-end
- X g goto-line
- X < goto-line
- X \33< goto-line
- X ' goto-mark
- X ^X^X goto-mark
- X H help
- X N next-file
- X % percent
- X p percent
- X P prev-file
- X q quit
- X ZZ quit
- X ^L repaint
- X ^R repaint
- X r repaint
- X R flush-repaint
- X n repeat-search
- X m set-mark
- X ! shell
- X = status
- X ^G status
- X - toggle-option
- X _ display-option
- X V version
- X v visual
- X
- X Commands specified by _l_e_s_s_k_e_y take precedence over the
- X default commands. A default command key may be disabled by
- X including it in the key file with the action "invalid".
- X
- X
- X SSSSEEEEEEEE AAAALLLLSSSSOOOO
- X less(1)
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X Page 2 (printed 7/19/88)
- X
- X
- X
- END_OF_FILE
-
-
-